/****
 * Copyright (C) 2006 dNux Team
 *                                                            ****
 * This program is free software; you can redistribute it and/or *
 * modify under the terms of the GNU General Public License as   *
 * published by the Free Software Foundation;                    *
 * either version 2 of the License.                              *
 *                                                               *
 * This program is distributed in the hope that it will be       *
 * useful, but WITHOUT ANY WARRANTY; without even the implied    *
 * warranty of without even the implied waranty of               *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          *
 * See the GNU General Public License for more details.          *
 *                                                               *
 * You should have received a copy of the                        *
 * GNU General Public License                                    *
 * along with this program; if not, write to the                 *
 * Free Software Foundation, Inc.,                               *
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. *
 *                                                               *
 ****                                                         ****/

#include "dcore.h"

d_error_t *
d_error_new(char *where, char *message, char *file, int line)
{
  d_error_t *new;
  new = (d_error_t *) malloc(sizeof(d_error_t));
  new->where = where;
  new->message = message;
  new->file = file;
  new->line = line;

  return new;
}

void
d_error_free(d_error_t **error)
{
  if ( *error ) free(*error);
  *error = NULL;
}

char *
d_error_get_message(d_error_t *error)
{
  return error->message;
}

int
d_error_get_line(d_error_t *error)
{
  return error->line;
}

char *
d_error_get_file(d_error_t *error)
{
  return error->file;
}

char *
d_error_get_where(d_error_t *error)
{
  return error->where;
}

void
d_error_display(d_error_t *error)
{
    fprintf(stderr, "Error in %s, %s:%d => %s\n",
	    error->where, error->file, error->line, error->message);
}
